
{% extends 'base.html' %}

{% block css%}
<style type="text/css">

.display_resp {
	background: #FFFFCC;
}

</style>
{% endblock %}

{% block body%} 
<div class="row">

		<div class="col-md-4">
	  	<h3>DDM</h3>
		<table class="table table-hover .table-responsive table-condensed">
			<tr>
				<td width="45%" style="line-height: 32px">
					TX Power (dbm)
				</td>
				<td class="display_resp">
					<span id="tx_power_text">---</span>
				</td>
<!-- 
				<td>
					<input type="text" id="tx_power_val" style="width:100px; height:30px">
					<button id="btn_set_tx_power" class="btn btn-primary">Set</button>
				</td> -->
			</tr>
			<tr>
				<td style="line-height: 32px">
					RX Power (dbm)
				</td>
				<td class="display_resp">
					<span id="rx_power_text">---</span>
				</td>
			</tr>

<!-- 			<tr class="<?= $Debug?>">
				<td style="line-height: 32px">
					Siop (dbm)
				</td>
				<td class="display_resp">
					<span id="siop_text">---</span>
				</td>
			</tr>
 -->

 			<tr>
				<td style="line-height: 32px">
					Vcc (V)
				</td>
				<td class="display_resp">
					<span id="vcc_text">---</span>
				</td>
			</tr>	


			<!-- COSA Temperature： COSA_TEMP_OUT 
			PCBA Temperature ：PCB_TEMP_ADC   -->

			<tr>
				<td style="line-height: 32px">
					COSA Temperature (ºC)
				</td>
				<td class="display_resp">
					<span id="cosa_temp_text">---</span>
				</td>
			</tr>

			<tr>
				<td style="line-height: 32px">
					PCBA Temperature (ºC)
				</td>
				<td class="display_resp">
					<span id="pcba_temp_text">---</span>
				</td>
			</tr>
			
			<tr>
				<td style="line-height: 32px">
					Case Temperature (ºC)
				</td>
				<td class="display_resp">
					<span id="case_temp_text">---</span>
				</td>
			</tr>


			<tr>
				<td style="line-height: 32px">
				Laser Temperature (ºC)
				</td>
				<td class="display_resp">
					<span id="laser_temp_text">---</span>
				</td>
			</tr>

			<tr>
				<td style="line-height: 32px">
				DSP Temperature (ºC)
				</td>
				<td class="display_resp">
					<span id="dsp_temp_text">---</span>
				</td>
			</tr>

			<tr>
				<td style="line-height: 32px">
				DSP Die Temperature (ºC)
				</td>
				<td class="display_resp">
					<span id="dsp_die_temp1">---</span>
					&nbsp;&nbsp;
					<span style="color: #ccc">hrx2</span><br>

					<span id="dsp_die_temp2">---</span>
					&nbsp;&nbsp;
					<span style="color: #ccc">lrx</span><br>

					<span id="dsp_die_temp3">---</span>
					&nbsp;&nbsp;
					<span style="color: #ccc">ltx_v</span><br>

					<span id="dsp_die_temp4">---</span>
					&nbsp;&nbsp;
					<span style="color: #ccc">htx_top0</span><br>
				</td>
			</tr>



<!-- 			<tr class="<?= $Debug?>">
				<td style="line-height: 32px">
					DSP Junction Temperature (ºC)
				</td>
				<td class="display_resp">
					<span id="dsp_junction_temp_text">---</span>
				</td>
			</tr> -->

<!-- 			<tr class="<?= $Debug?>">
				<td style="line-height: 32px">
					DSP Junction Avg Temperature (ºC)
				</td>
				<td class="display_resp">
					<span id="dsp_avg_temp_text">---</span>
				</td>
			</tr> -->

			<tr>
				<td style="line-height: 32px" colspan="5">
					<button id="btn_get_ddm_values" class="btn btn-success pull-left">Get</button>
				</td>
			</tr>
		</table>

	  </div>

	  <div class="col-md-8">

		<h3>VDM Decode</h3>
		<div id="vdm_all_info">
		</div>
		<button type="button" class="btn btn-success get_vdm_decode_btn">
		 Get VDM Decode
		</button>
		<br><br>
	  </div>

</div>
{% endblock %}

{% block js%} 
{{ super() }}
<script type="text/javascript">

	$(document).ready(function(){

	    // get vdm all info
	    $(".get_vdm_decode_btn").click(function() {
	      $.get("api/get_vdm_decode", function(data, status){
	        console.log(data);
	        // $("#img_fcr_capture").attr('src', data);
	        $("#vdm_all_info").html(data);
	      }); 
	      
	    });

		$("#btn_get_ddm_values").click(function(){
			console.log("btn_get_ddm_values...");

			url = "api/get_ddm_values";
			$.get(url, function(data, status){
				console.log(data);
				ret = data.split(',')
				$("#tx_power_text").html(ret[0]);
				$("#rx_power_text").html(ret[1]);
				// $("#siop_text").html(ret[2]);
				$("#vcc_text").html(ret[2]);

				$("#cosa_temp_text").html(ret[3]);
				$("#pcba_temp_text").html(ret[4]);
				

				$("#case_temp_text").html(ret[5]);
				$("#laser_temp_text").html(ret[6]);
				$("#dsp_temp_text").html(ret[7]);

				$("#dsp_die_temp1").html(ret[8]);
				$("#dsp_die_temp2").html(ret[9]);
				$("#dsp_die_temp3").html(ret[10]);
				$("#dsp_die_temp4").html(ret[11]);

				// $("#dsp_junction_temp_text").html(ret[5]);
				// $("#dsp_avg_temp_text").html(ret[6]);
			});
		});

		// $("#btn_set_tx_power").click(function(){
		// 	var tx_power_val =  $("#tx_power_val").val();
		// 	console.log("btn_set_tx_power...");
		//     $.post(
		//         "api/set_tx_power", {
		//             tx_power_val: tx_power_val
		//         },
		//         function(data, status) {
		//             console.log("data: " + data);
		//         }
		//     );
		// });

	});
</script>
{% endblock %}